const express = require('express')

const {
	addUser,
	listUser,
	updatePassword,
} = require('../modules/module-user')

const router = express.Router()

// /ult/user/list
router.post('/user/list', function(req, res, next) {
	listUser().then(result => {
		res.type('json').send(result)
	})
})

// /ult/user/add
router.post('/user/add', function(req, res, next) {
	let params = req.body
	addUser(params).then(result => {
		res.type('json').send(result)
	})
})

// /ult/user/update
router.post('/user/update', function(req, res, next) {
	updatePassword(req.body).then(result => {
		res.type('json').send(result)
	})
})

module.exports = router